package com.cpf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author cpf email: cpfprogrammer@163.com
 * @date 2022/5/17 下午3:52
 */
@Controller
@RequestMapping("/redirect")
public class RedirectController {

    @GetMapping("/m1")
    public ModelAndView redirect1(){
        return new ModelAndView("redirect:http://www.baidu.com");
    }

    @GetMapping("/m2")
    public String redirect2(){
        return "redirect:http://www.baidu.com";
    }

    @GetMapping("/m3")
    public void redirect3(HttpServletResponse response) throws IOException {
        response.sendRedirect("http://www.baiud.com");
    }

}
